/**
 * @author 橘柚
 * @Date 2023/11/11 15:58
 * @Description 处理懒加载组件加载不到
 */
import React from "react";
import {Navigate} from "react-router-dom";

interface IPros {
  children: React.ReactNode
}

class LazyLoadBoundary extends React.Component<IPros, { hasError: boolean }> {

  state = {
    hasError: false
  }

  static getDerivedStateFromError() {
    return {hasError: true};
  }

  render() {
    return this.state.hasError ? <Navigate to="/load-error" replace/> : this.props.children;
  }
}

export default LazyLoadBoundary
